package top.abrsm.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class MvcWebConfig implements WebMvcConfigurer {


    @Override
    public void addViewControllers (ViewControllerRegistry registry) {
        registry.addViewController ( "/toLogin" ).setViewName ( "login" ); // 加载登录页面
        registry.addViewController ( "/toRegister" ).setViewName ( "register" ); // 加载登录页面
        registry.addViewController ( "/forget" ).setViewName ( "forget" ); // 加载练习记录
        registry.addViewController ( "/agreement" ).setViewName ( "agreement" ); // 加载用户协议页面

    }

    @Resource
    private StoreInterceptor storeInterceptor;

    @Override
    public void addInterceptors (InterceptorRegistry registry) {
        String arrays[] = {"/pay/wxPay", "/car/saveSingle", "/car/queryList", "/order/queryList", "/order/createOrder", "/order/deleteSingle", "/order/queryReceipt", "/order/orderInfo", "/address/getAddressList", "/express/querySingle"};
        registry.addInterceptor ( storeInterceptor ).addPathPatterns ( arrays );
    }
}
